package com.design.structure.decorator.atguigu;

/**
 * @ProjectName: design
 * @Package: com.design.structure.decorator.atguigu
 * @ClassName: Decorator
 * @Author: shenaiguo
 * @Description: 装饰者
 * @Date: 2020/9/6 0006 10:12
 */
// 步骤 4
public class Decorator extends Drink {
    private Drink obj;

    public Decorator(Drink obj) { //组合

        this.obj = obj;
    }

    @Override
    public float cost() {

// getPrice 自己价格
        return super.getPrice() + obj.cost();
    }

    @Override
    public String getDes() {

// obj.getDes() 输出被装饰者的信息
        return des + " " + getPrice() + " && " + obj.getDes();
    }
}
